home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1994 / MacHack 1994.toast / MacHack™94 / Miscellaneous / Randy Thelen / ThreadedSort / Interfaces / Window.h < prev   
Encoding:
C/C++ Source or Header  |  1994-06-26  |  3.0 KB  |  127 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        Window.h
  3.  
  4.     Contains:    Definition of TWindow, a base class which provides a
  5.                 framework for building way-cool windows which even John
  6.                 Sullivan would be happy with. Floating windows and “smart
  7.                 zooming” algorithms are based on code samples provided by
  8.                 Dean Yu.
  9.                 
  10.     Written by: Dave Falkenburg, Dean Yu
  11.  
  12.     Copyright:    © 1993-94 by Dave Falkenburg, all rights reserved.
  13.  
  14.     Change History (most recent first):
  15.      
  16.  */
  17.  
  18. #ifndef        _WINDOW_
  19. #define        _WINDOW_
  20.  
  21. #ifndef        __TYPES__
  22. #include    <Types.h>
  23. #endif
  24.  
  25. #ifndef        __WINDOWS__
  26. #include    <Windows.h>
  27. #endif
  28.  
  29. #ifndef        __EVENTS__
  30. #include    <Events.h>
  31. #endif
  32.  
  33. #ifndef        __DRAG__
  34. #include    <Drag.h>
  35. #endif
  36.  
  37. //    Useful synonyms
  38.  
  39. #define        kNormalWindow        false
  40. #define        kFloatingWindow        true
  41.  
  42. typedef    short    WindowTemplateID;
  43.  
  44.  
  45. class    TWindow
  46.     {
  47. protected:
  48.     WindowPtr            fWindow;
  49.     Boolean                fIsFloatingWindow;
  50.     Boolean                fIsVisible;
  51.     
  52. public:
  53.                         TWindow();
  54.     virtual                ~TWindow();
  55.  
  56.     //    Event routing methods
  57.  
  58.     virtual    Boolean        EventFilter(EventRecord * theEvent);    
  59.  
  60.     //    Methods you shouldn’t need to override, but might need to
  61.  
  62.     virtual void        CreateWindow(Boolean isFloating);
  63.     virtual    void        Select(void);
  64.     virtual    void        Drag(Point startPoint);
  65.     virtual void        Grow(Point startPoint);
  66.     virtual void        Zoom(short zoomState);
  67.  
  68.     //    Wrapper for ShowHide so we can correctly show and hide
  69.     //    floating windows when a major context switch occurs
  70.     
  71.     virtual void        ShowOrHide(Boolean showFlag);
  72.  
  73.     //    Methods which MUST be overridden:
  74.  
  75.     virtual WindowPtr    MakeNewWindow(WindowPtr behindWindow)    = 0;
  76.     
  77.  
  78.     //    Methods which probably should be overridden
  79.  
  80.     virtual    void        AdjustCursor(EventRecord * anEvent);
  81.     virtual void        Idle(EventRecord * anEvent);
  82.     virtual void        Activate(Boolean activating);
  83.     virtual void        Draw(void);
  84.     virtual void        Click(EventRecord * anEvent);
  85.     virtual    void        KeyDown(EventRecord * anEvent);
  86.  
  87.     virtual void        GetPerfectWindowSize(Rect * perfectSize);
  88.     virtual    void        GetWindowSizeLimits(Rect * limits);
  89.     virtual void        AdjustForNewWindowSize(Rect * oldRect,Rect * newRect);
  90.  
  91.  
  92.     //    Window property accessor methods…
  93.     //        …watch for new ones when we add scripting support    
  94.     
  95.     virtual    Boolean        IsVisible(void);
  96.     
  97.     virtual    Boolean        CanClose(void);        
  98.     virtual    Boolean        Close(void);
  99.     virtual    Boolean        DeleteAfterClose(void);
  100.     
  101.     virtual    Boolean        CanEdit(void);
  102.     virtual void        DoEditMenu(short menuCode);
  103.  
  104.  
  105.     //    Methods for use with the Drag Manager
  106.     
  107.     virtual    OSErr        HandleDrag(DragTrackingMessage dragMessage,DragReference theDrag);
  108.     virtual    OSErr        HandleDrop(DragReference theDragRef);
  109.     };
  110.  
  111.  
  112. //    Utility Functions:
  113.  
  114. TWindow *            GetWindowObject(WindowPtr aWindow);
  115.  
  116. WindowPtr            LastFloatingWindow(void);
  117. WindowPtr            FrontNonFloatingWindow(void);
  118.  
  119. void                HiliteAndActivateWindow(WindowPtr aWindow,Boolean active);
  120. void                SuspendResumeWindows(Boolean resuming);
  121. void                HiliteWindowsForModalDialog(Boolean hiliting);
  122.  
  123. pascal OSErr        CallWindowDragTrackingHandler(DragTrackingMessage message,WindowPtr theWindow,void *handlerRefCon,DragReference theDragRef);
  124. pascal OSErr        CallWindowDragReceiveHandler(WindowPtr theWindow, void *handlerRefCon,DragReference theDragRef);
  125.  
  126. #endif
  127.